package com.kk.model;

import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NonNull;
import org.hibernate.annotations.GenericGenerator;

import javax.persistence.*;

/**
 * @author: kevin
 * @data: 2018-08-20 23:52
 * @desc:
 */
@EqualsAndHashCode(callSuper = true)
@Data
@Entity
public class RoleMenuRel extends BaseEntity{

    @ManyToOne
    private Role role;

    @ManyToOne
    private Menu menu;

    //排序   注意：此处如果直接使用order会报错，因为order在sql中是关键字，故使用_order还是有道理的
    @Column(nullable = true)
    private int sort;

    private String menuName;

    private String roleName;

    public RoleMenuRel() {

    }

    public RoleMenuRel(Role role, Menu menu) {
        this.role = role;
        this.menu = menu;
        this.roleName = role.getName();
        this.menuName = menu.getName();
    }
}
